package com.itheima03.day16test;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author 刘全
 * @date 2021/8/10
 */
public class ServerTest4 {
    public static void main(String[] args) throws IOException {
        /**
         * 4. 使用TCP完成简单的数据传输
         *     发送端发送，接收端接收
         */
        ServerSocket ss = new ServerSocket(10086);

        Socket accept = ss.accept();

        InputStream is = accept.getInputStream();
        byte[] bytes = new byte[1024];
        int len;
        while ((len = is.read(bytes)) != -1) {
            System.out.print(new String(bytes,0,len));
        }
        accept.close();
        ss.close();
    }
}
